package cn.sundat.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;

import cn.sundat.model.Category;
import cn.sundat.model.News;
import cn.sundat.service.CategoryService;
import cn.sundat.service.FriendLinkService;
import cn.sundat.service.NewsService;


public class IndexAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String getcontent() throws Exception {
		
		String title= ServletActionContext.getRequest().getParameter("title");
		String content= ServletActionContext.getRequest().getParameter("content");
		System.out.println(title);
		System.out.println(content);
		return NONE;
	}
	
	@Resource(name="categoryService")
	private CategoryService categoryService;
	@Resource(name="friendLinkService")
	private FriendLinkService friendLinkService;
	@Resource(name="newsService")
	private NewsService newsService;
	/**
	 * 初始化网站导航
	 * @return
	 */
	public String init() {
		Category c = new Category();
		//导航条查询
//		List<Category> clist = categoryService.findCategoryAll();
		//协会动态
		c.setCate_id(3L);
		List<News> dongtai = newsService.findByCategory(c);
		//图片新闻
		List<News> tupian = newsService.findImgByCategory(c);
		//通知公告
		c.setCate_id(9L);
		List<News> tongzhi = newsService.findByCategory(c);
		//信用信息
		c.setCate_id(10L);
		List<News> xyxx = newsService.findByCategory(c);
		//信用资料
		c.setCate_id(11L);
		List<News> xyzl = newsService.findByCategory(c);
		//相关政策
		c.setCate_id(4L);
		List<News> zhengce = newsService.findByCategory(c);
		//协会简介
		
		//会员风采
		c.setCate_id(12L);
		List<News> fengcai = newsService.findByCategory(c);
		//压栈
		ValueStack vs = ActionContext.getContext().getValueStack();
		String news = ServletActionContext.getRequest().getParameter("editorValue");
//		vs.set("friendLinkList", friendLinkService.findAllFriendLink());
//		vs.set("sysinfo", friendLinkService.findAllInfo());
		vs.set("dongtai", dongtai);
		vs.set("tupian", tupian);
		vs.set("zhengce", zhengce);
		vs.set("tongzhi", tongzhi);
		vs.set("xyxx", xyxx);
		vs.set("xyzl", xyzl);
		vs.set("fengcai", fengcai);
		ActionContext.getContext().getApplication().put("sysinfo", friendLinkService.findAllInfo());
		ActionContext.getContext().getApplication().put("friendLinkList", friendLinkService.findAllFriendLink());
		return "in";
	}
}
